<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<meta name="decorator" content="sysDefault"/>
	<script src="${staticPath}/lib//jquery/1.10.2/jquery.js" type="text/javascript"></script>
	<script src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js" type="text/javascript"></script>
	<link rel="stylesheet" href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript">
		var siteNavId = "<c:out value="${siteNav.id}"/>";
		var siteNavName = "<c:out value="${siteNav.name}"/>";
		var zNodes;
		var _treeNode;
		var dragId;
		var log, className = "dark", startTime = 0, endTime = 0, perCount = 100, perTime = 100;
		var setting = {
			view : {
				selectedMulti : false,
				fontCss : getFont,
				nameIsHTML : true
			},
			edit : {
				enable : true,
				editNameSelectAll : false,
			},
			check : {
				enable : true,
				chkStyle: "radio",
				radioType: "all"

			},
			data : {
				simpleData : {
					enable : true
				}
			},
			callback : {
				beforeRemove : beforeRemove,
				beforeEditName : beforeEditName,
				beforeDrop : beforeDrop,
				onClick : onClick,
				onCheck: zTreeOnCheck
			}
		};
		function getFont(treeId, node) {
			return node.font ? node.font : {};
		}
		
		//编辑
		function beforeEditName(treeId, treeNode) {
			url = '${contextPath}/sys/sitenavmenu/edit?siteNavMenuId='+treeNode.id;
			window.open(url, '_self');
			return false;
		}
		
		//删除
		function beforeRemove(treeId, treeNode) {
			var flag = confirm("删除节点 --" + treeNode.name + " -- 所属子节点也会被同时删除,确认删除？");
			if (flag) {
				window.location.href = "${contextPath}/sys/sitenavmenu/delete?siteNavMenuId="+treeNode.id+"&siteNavId="+siteNavId;
			}
			return flag;
		}
		
		function beforeDrop(treeId, treeNodes, targetNode, moveType) {
			return false;
		}
		
		//点击
		function onClick(event, treeId, treeNode, clickFlag) {
			url = '${contextPath}/sys/sitenavmenu/view?siteNavMenuId='+treeNode.id;
			window.open(url, '_self');
		}
		
		//勾选事件
		function zTreeOnCheck(event, treeId, treeNode){
			if(treeNode.checked == true){//已勾选、
				_treeNode = treeNode;
			}else {//未勾选、
				_treeNode = "";
			}
		}
		
		//初始化
		$(document).ready(function() {
			$.get("${contextPath}/sys/sitenavmenu/getNode?siteNavId="+ siteNavId, function(data) {
				$('#result').text(data);//直接展示JSON数据
				zNodes = eval("(" + data + ")");
				$.fn.zTree.init($("#menuTree"), setting, zNodes);
			});
			//如果是下拉导航则不展示新增导航菜单按钮
			var isDropdown = "<c:out value="${siteNav.isDropdown}"/>";
			if(isDropdown == 1){
				$('#add').attr("disabled", "disabled");
			}
		});
		
		//新增
		function funform(url, target) {
			var treeId;
			var treeName;
			var treeIsParent;
			if (_treeNode != null) {
				treeId = _treeNode.id;
				treeName = _treeNode.name;
				treeIsParent = _treeNode.isParent;
			}
			if (treeId == "" || typeof (treeId) == "undefined") {
				window.open(url +"?siteNavId="+siteNavId,target);
			} else {
				window.open(url + "?parentId=" +treeId+"&parentName="+treeName+"&siteNavId="+siteNavId,target);
			}
		}
	</script>
	<style type="text/css">
		.ztree li span.button.switch.level0 {visibility:hidden; width:1px;}
		.ztree li ul.level0 {padding:0; background:none;}
	</style>
</head>
<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-xs-12">
				<div class="panel panel-default">
				  <div class="panel-heading">
				    <h3 class="panel-title">
				    	站点导航数据信息
						<a class="btn btn-default btn-sm pull-right" role="button" href="${contextPath}/sys/site/${siteNav.siteId}/view" >返回</a>
				    	<a class="btn btn-success btn-sm pull-right" style="color: white;" role="button" href="${contextPath}/sys/sitenav/edit?siteNavId=${siteNav.id}" >修改</a>
				    	<a class="btn btn-danger btn-sm pull-right" style="color: white;" role="button" href="${contextPath}/sys/sitenav/delete?siteNavId=${siteNav.id}&siteId=${siteNav.siteId}"
							onclick="return Oosp_Confirm('删除节点 -- ${siteNav.name} -- 所属子节点也会被同时删除,确认删除？', this.href)">删除</a>
				    
				    </h3>
				  </div>
				  	<tags:message content="${message}" />
				  	<table class="table table-bordered">
					  <tbody>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>名称:</strong></td>
					  		<td>
								${siteNav.name}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>排序号:</strong></td>
					  		<td>
								${siteNav.orderNo}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>目标:</strong></td>
					  		<td>
								${siteNav.target}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>链接地址:</strong></td>
					  		<td>
								${siteNav.href}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>是否是下拉导航:</strong></td>
					  		<td>
					  			<c:choose>
					  				<c:when test="${siteNav.isDropdown == 1}">
					  					是
					  				</c:when>
					  				<c:otherwise>
					  					否
					  				</c:otherwise>
					  			</c:choose>
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>上级导航:</strong></td>
					  		<td>
								${siteNav.parentName}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>层级ID:</strong></td>
					  		<td>
								${siteNav.hierarchicalId}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>备注:</strong></td>
					  		<td>
								${siteNav.remarks}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>是否显示:</strong></td>
					  		<td>
					  			<c:choose>
					  				<c:when test="${siteNav.isShow == 1}">
					  					是
					  				</c:when>
					  				<c:otherwise>
					  					否
					  				</c:otherwise>
					  			</c:choose>
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>所属站点:</strong></td>
					  		<td>
								${siteNav.siteName}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>权限标示:</strong></td>
					  		<td>
								${siteNav.permission}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>创建人:</strong></td>
					  		<td>
								${siteNav.createBy}
							</td>
					  	</tr>
					  	<tr>
					  		<td class="text-right" style="width: 20%"><strong>创建日期:</strong></td>
					  		<td>
								<fmt:formatDate value="${siteNav.createTime}" pattern="yyyy-MM-dd HH:mm:ss" />
							</td>
					  	</tr>
					  </tbody>
					</table>
				  <div class="panel-footer"></div>
				</div>
				
				<div class="panel panel-default">
					<div class="panel-heading">
					    <h3 class="panel-title">
					    <tags:message content="${message}"/>
					    	站点导航菜单管理<span class="glyphicon &{icon}"></span>
					    	<button id="add"  class="btn btn-success btn-sm pull-right" role="button" onclick="funform('${contextPath}/sys/sitenavmenu/add','_self');">新增</button>
					    </h3>
					</div>
					<ul id="menuTree" class="ztree" ></ul>
				</div>
			</div>
		</div>
	</div>
</body>
</html>